[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 getpalette()            Get Current Palette and Size

 #include   <graphics.h>

 void far               getpalette(palette);
 struct palettetype far *palette;

    getpalette() retrieves the current palette by filling in the
    'palettetype' structure pointed to by 'palette'.  'palettetype' is
    defined in <graphics.h> as:

     struct palettetype {
          unsigned char size;
          signed char colors[MAXCOLORS+1];
     };

    MAXCOLORS is a constant defined in <graphics.h> as:

     #define MAXCOLORS 15

    'size' is a value which represents the number of colors in the
    current palette.  'colors' is an array of 'size' bytes which contains
    the actual color values for the palette.

    Returns:    Nothing.

   -------------------------------- Example ---------------------------------

    The following statements load 'palette' with the palette size and
    colors and then, in turn, fill a rectangle with all the available
    colors.

           #include <graphics.h>
           #include <conio.h>

           int gdriver = DETECT;
           int gmode;

           main()
           {
               int whcolor;
               struct palettetype palette;

               initgraph(&gdriver,&gmode,"");
               getpalette(&palette);
               for (whcolor = 0; whcolor < palette.size; whcolor++) {
                   setfillstyle(SOLID_FILL,whcolor);
                   rectangle(100,100,200,150);
                   floodfill(110,110,WHITE);
                   getch();
               }
               closegraph();
           }


See Also: initgraph() getgraphmode()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson